#pragma once
#include <forward_list>

template<typename T>
class sliding_list 
{
public:

	sliding_list(size_t max):_max(max), _count(0) {}

private:

	size_t _count;

	size_t _max;

	std::list<T> _data;

public:

	bool is_full()const
	{
		return _count == _max;
	}

	void add_to(const T& data)
	{
		if(is_full())
		{
			_data.pop_front();
		}
		else
		{
			_count++;
		}
		_data.push_back(data);
	}

	auto begin()const
	{
		return _data.begin();
	}

	auto end()const
	{
		return _data.end();
	}

	size_t count()const
	{
		return _count;
	}
};

